package cn.jsj.machine.service.impl;

import cn.jsj.machine.dao.IUserDao;
import cn.jsj.machine.exceptions.MyRuntimeParamsException;
import cn.jsj.machine.pojo.CUser;
import cn.jsj.machine.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import static org.springframework.transaction.annotation.Isolation.REPEATABLE_READ;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private IUserDao userDao;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = REPEATABLE_READ)
    public Integer userLogin(Integer account, String password) {
        CUser user = this.userDao.getOneUserByAccountAdnPassword(account,password.trim());
        if(user == null){
            return -1;
        }
        Integer t =  user.getUserType();
        return t;
    }

}
